from django.db import models


# Create your models here.
class User(models.Model):
    email = models.EmailField(unique=True)
    password = models.CharField(max_length=80)
    state = models.IntegerField(default=0)
    create_time = models.DateTimeField(auto_now_add=True)
    update_time = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'user'


# 用户详情模型类
class UserDetail(models.Model):
    nickname = models.CharField(max_length=40, unique=True, null=True)
    portrait = models.TextField(null=True)
    phone = models.CharField(max_length=12, unique=True, null=True)
    age = models.IntegerField(null=True)
    sex = models.IntegerField(null=True)
    address = models.TextField(null=True)
    birthday = models.DateField(null=True)
    user = models.OneToOneField(User, on_delete=models.CASCADE)

    class Meta:
        db_table = 'user_detail'
